package chapter03;

public class Test_Car {
    public static void main(String[] args) {
        Car c1 = new Car();
        c1.brand = "宝马";
        c1.type = "混动";
        c1.drive();
        //new 代表了在堆内存空间开辟了一个car的空间 将c1的属性值放入
        Car c2 = c1;
        c2.drive();
        //更改c2的属性  c1会不会一起更改呢 是一起更改的
        c2.brand = "奔驰";
        c2.drive();
        c1.drive();
        //定义一个c3
        Car c3 = new Car();
        c3.brand = "奔驰";
        c3.type = "混动";
        c3.drive();
    }
}
class Car{
    String brand;
    String type;//电动车 油车 混动
    void drive(){
        System.out.println(brand+"的汽车行驶公路上，是一辆"+type+"车");
    }
}
